package huang.com.android.searchmanagerdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SearchManagerAcitvity extends AppCompatActivity implements View.OnClickListener {
    public EditText etdata;
    public Button btcall;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.search_manager_acitvity);

        etdata = (EditText) findViewById(R.id.etdata);
        btcall = (Button) findViewById(R.id.btcall);
        btcall.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        onSearchRequested();
    }

    /*
     * 为了能够使用search bar,我们必须重写Activity的onSearchRequested的方法，
     * search bar不会自动触发，必须通过一个按钮或者菜单的点击事件触发
     * @see android.app.Activity#onSearchRequested()
     */

    @Override
    public boolean onSearchRequested() {
        String text = etdata.getText().toString();
        Bundle bundle = new Bundle();
        bundle.putString("data",text);

        startSearch("hwang",false,bundle,false);

        return true;
    }

}
